package com.oa.controller;

import com.oa.back.ResponseBack;
import com.oa.common.annotion.Interceptor;
import com.oa.common.enums.CodeStatus;
import com.oa.common.vo.FormVo;
import com.oa.service.FormService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/manage/form")
public class FormController extends BaseController {

    private static final Logger logger= LoggerFactory.getLogger(FormController.class);

    @Autowired
    private FormService formService;

    @RequestMapping(value = "submit",method = RequestMethod.POST)
    @ResponseBody
    @Interceptor(actionName = "提交表单的接口")
    public ResponseBack<FormVo> submit(String params){
        try{
            return formService.submit(params);
        }catch (RuntimeException ex){
            logger.error("提交表单接口的异常:",ex);
            return ResponseBack.fial(CodeStatus.SYSTEM_FAIL.getResponseStatus());
        }
    }
}
